<template>
  <div>
    <!--tab start-->
    <el-tabs v-model="tabName">
      <el-tab-pane label="查询服务商" name="searchSpPage">
        <SpPage v-if="tabName==='searchSpPage'" :tab-name="tabName" />
      </el-tab-pane>
      <!--<el-tab-pane label="全部服务商" name="spPage">-->
      <!--  <SpPage v-if="tabName==='spPage'" :tab-name="tabName" />-->
      <!--</el-tab-pane>-->
      <el-tab-pane v-if="$isAuthBtn(['SP_TAB_SUB_SP_ADD'])" label="添加服务商" name="spForm">
        <SpForm v-if="tabName==='spForm'" :tab-name.sync="tabName" @updateTabName="getUpdateTabName" />
      </el-tab-pane>
    </el-tabs>
    <!--tab end-->

    <!-- 一级服务商未填写斗拱分账接收方相关资料时，登录进入服务商后台强制弹窗提示： -->
    <el-dialog
      v-loading.fullscreen.lock="fullscreenLoading"
      title="提示"
      :visible.sync="centerDialogVisible"
      width="50%"
      :close-on-click-modal="false"
      center
    >
      <span>请及时补充渠道资料，以保证您的代理展业和商户收单不受影响</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="supp">去补充</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  detail
} from '@/api/user/auth'
import SpPage from './components/SpPage'
import SpForm from './components/SpForm'
import { mapGetters } from 'vuex'
export default {
  components: {
    SpPage,
    SpForm
  },
  data() {
    return {
      centerDialogVisible: false,
      fullscreenLoading: true,
      // 配置
      // 状态
      // 数据
      tabName: 'searchSpPage'
    }
  },
  computed: {
    ...mapGetters(['agentFlow', 'spInfo'])
  },
  watch: {},
  beforeCreate() {
  },
  created() {
  },
  beforeMount() {
  },
  mounted() {
    if (this.spInfo && this.spInfo.roleAlias === 'boss') {
      this.getDetaildata()
    }
  },
  beforeUpdate() {
  },
  update() {
  },
  activated() {
  },
  deactivated() {
  },
  beforeDestroy() {
  },
  destroyed() {
  },
  methods: {
    // 取消
    cancel() {
      this.centerDialogVisible = false
    },
    // 查询补充资料
    // 渠道补充信息详情
    getDetaildata() {
      // const params = { userId: this.userInfo.id }
      this.fullscreenLoading = true
      detail().then(res => {
        console.log('渠道补充信息详情', res)
        this.fullscreenLoading = false
        if (res.succeed) {
          if (JSON.stringify(res.data) === '{}' || res.data === null) {
            this.centerDialogVisible = true
          } else {
            this.centerDialogVisible = false
          }
        }
      })
    },
    // 补充资料
    supp() {
      this.$router.push({ name: 'SystemSuppData' })
      this.centerDialogVisible = false
    },
    /**
     * 数据组
     */
    /**
     * 按钮组
     */
    /**
     * 状态组
     */
    getUpdateTabName(val) {
	  this.tabName = val
    }
    /**
     * 方法组
     */
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>

</style>
